package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;
    @GetMapping("/user")
    public Result getUser(){
        return  Result.success("hello");
    }
    @GetMapping("/users")
    public Result<List<User>> getUsers(){
        //调用服务层获取用户列表
        List<User> users = userService.list();
        //使用装装的Result类返回
        return Result.success(users);
    }


}
